<template>
  <div class="card-box" :style="ewmStyles">
    <div class="card-tit">
      <img src="@/assets/img/home-ewm.png" alt="" class="mr6">
      二维码管理
    </div>
    <div class="mt60 flex flex-x-center">
      <div style="margin-right: 20%;">
        <img :src="miniProgram" alt="" class="disblock mauto" style="width: 120px;height: 120px;">
        <div class="font12 color333 line17 mt20 tc">医保社保缴费小程序
          <a @click="download(miniProgram,'医保社保缴费小程序.jpg')"><img src="@/assets/img/download.png" alt=""
                                                                 class="ml4"></a>
        </div>
      </div>
      <div>
        <img src="@/assets/img/home-serviceQrCode.png" alt="" class="disblock mauto"
             style="width: 120px;height: 120px;">
        <div class="font12 color333 line17 mt20 tc">扫码联系客服</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "qrCodeManagement",
  props: {
    authorityList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  computed: {
    // 二维码高度
    ewmStyles() {
      let height = '746px';
      if (!this.authorityList.includes('yibaoyuanxingtu') && !this.authorityList.includes('yibaozhexiantu')) {
        height = '382px';
      }
      if (!this.authorityList.includes('shebaoyuanxingtu') && !this.authorityList.includes('shebaozhexiantu')) {
        height = '382px';
      }
      if (!this.authorityList.includes('yibaozhexiantu') && !this.authorityList.includes('shebaozhexiantu')) {
        height = '382px';
      }
      return 'height: ' + height;
    }
  },
  data() {
    return {
      miniProgram: process.env.NODE_ENV === 'production' || process.env.VUE_APP_EVN_CONFIG === 'pro' ? require('@/assets/img/home-miniProgram.jpg') : require('@/assets/img/home-miniProgramTrial.jpg'),
    }
  },
  methods: {
    // 图片下载
    download(url, name) {
      if (!url) {
        return;
      }
      var a = document.createElement("a")
      a.setAttribute("href", url)
      a.setAttribute("download", name);
      a.setAttribute("target", "_blank")
      let clickEvent = document.createEvent("MouseEvents");
      clickEvent.initEvent("click", true, true);
      a.dispatchEvent(clickEvent);
    },
  }
}
</script>

<style scoped>
@import "../style.less";
</style>
